var classes = new Array();
var condition = new Array();


function selectClasses(){
	$.ajax({
		url: 'https://www.supertimor.cn/media_project/index.php/check/selectClasses',
		method: 'post',
		header: 'Content-Type: application/x-www-form-urlencoded',
		async:false,
		success: function(e) {
			e.result.forEach(function(value, index) {
				classes.push(value.name);
			});
			$('#classes').select({
				input: classes[0],
				title: "请选择报销事项",
				items: classes,
				onClose: function(d) {
					selectDetail(d.data.values);
				}
			});
		}
	})
}

function selectDetail(values){
	$.ajax({
		url: 'https://www.supertimor.cn/media_project/index.php/check/selectDetail',
		method: 'post',
		header: 'Content-Type: application/x-www-form-urlencoded',
		async:false,
		data: {
			classes: values
		},
		success: function(e) {
			condition=[]
			e.result.forEach(function(value, index) {
				condition.push(value.condition);
			});
			$('#condition').off().val('').data('weui-select',false).select({
				input: condition[0],
				title: "请报销金额",
				items: condition,
				onClose: function(d) {
					selectProcedure(values,d.data.values);
				}
			});
			selectProcedure(values,e.result[0].condition)
		}
	})
}

function selectProcedure(values1,values2){
	$.ajax({
		url: 'https://www.supertimor.cn/media_project/index.php/check/selectProcedure',
		method: 'post',
		header: 'Content-Type: application/x-www-form-urlencoded',
		async:false,
		data: {
			classes: values1,
			condition: values2
		},
		success: function(e) {
			console.log(e)
			$("#procedure").text("审批需经过"+e.result[0].procedure)
		}
	})
}



selectClasses();
selectDetail(classes[0]);
selectProcedure(classes[0],condition[0]);

